package jp.co.ricoh.melody.presenters;

import android.content.Context;
import jp.co.ricoh.melody.models.entities.SoundData;
import jp.co.ricoh.melody.views.fragments.SDCardSoundListDialogFragment;
import jp.co.ricoh.melody.views.fragments.SoundListDialogFragment;

/**
 * Copyright (C) 2016 RICOH Co.,LTD.
 * All rights reserved.
 * Presenter of SoundListDialogFragment.
 * This class is used to control function of view.
 */
public class SoundListDialogFragmentPresenter implements ISoundListDialogFragmentPresenter {
    private SoundListDialogFragment.OnSoundDialogDismissListener mOnSoundDialogDismissListener;
    private SDCardSoundListDialogFragment.OnSoundDialogDismissListener mOnSDCardSoundDialogDismissListener;

    /**
     * Create presenter.
     *
     * @param context
     * @param onSoundDialogDismissListener
     */
    @Override
    public void onCreate(Context context, SoundListDialogFragment.OnSoundDialogDismissListener onSoundDialogDismissListener) {
        mOnSoundDialogDismissListener = onSoundDialogDismissListener;
    }

    @Override
    public void onCreate(Context context, SDCardSoundListDialogFragment.OnSoundDialogDismissListener onSoundDialogDismissListener) {
        mOnSDCardSoundDialogDismissListener = onSoundDialogDismissListener;
    }

    /**
     * This method is used to select sound for melody.
     *
     * @param soundData
     */
    @Override
    public void onCompletedSelectSound(SoundData soundData) {
        if(mOnSoundDialogDismissListener != null) {
            mOnSoundDialogDismissListener.onDismiss(soundData);
        }


        if(mOnSDCardSoundDialogDismissListener != null) {
            mOnSDCardSoundDialogDismissListener.onDismiss(soundData);
        }
    }
}
